<template>
  
  <div class="All">
        <!-- 显示待审核的 -->
        <!-- <div v-for="(item) in Sdata" :key="item._id">
             <p>{{item.idCard}}</p>
             <button @click="argreeS(item._id,1)">同意审核</button>
             <button @click="argreeS(item._id,2)">不同意审核</button>
        </div> -->
        <el-table
    :data="Sdata"
    style="width: 100%">
    <el-table-column
      label="用户名"
      width="180">
      <template slot-scope="scope">
        <i class="el-icon-user"></i>
        <span style="margin-left: 10px">{{ scope.row.userName }}</span>
      </template>
    </el-table-column>
    <el-table-column
      label="身份信息"
      width="180">
      <template slot-scope="scope">
        <el-popover trigger="hover" placement="top">
          <p>身份证号: {{ scope.row.idCard }}</p>
          <p>身份证姓名: {{ scope.row.idName }}</p>
          <div slot="reference" class="name-wrapper">
            <el-tag size="medium">{{ scope.row.idCard }}</el-tag>
          </div>
        </el-popover>
      </template>
    </el-table-column>

    <el-table-column
      label="信用分"
      width="180">
       <template slot-scope="scope">
        <el-popover trigger="hover" placement="top">
          <p>信用分500为默认，越高越好</p>
          <div slot="reference" class="name-wrapper">
            <i class="el-icon-trophy"></i>
        <span style="margin-left: 10px">{{ scope.row.fraction }}</span>
          </div>
        </el-popover>
      </template>
     
    </el-table-column>

    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="argreeS(scope.row._id,1)">同意审核</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="argreeS(scope.row._id,2)">拒绝审核</el-button>
      </template>
    </el-table-column>
  </el-table>

  <el-pagination
  small
  layout="prev, pager, next"
  :page-size="limitpage*10"
  :current-page="pageNow"
  @current-change="toPage"
  @prev-click="prevPage"
  @next-click="nextPage"
  :total="total*10">
</el-pagination>
  </div>
</template>

<script>
import axios from 'axios';
export default {
      data(){
          return{
                Sdata:[],
                limitpage:2,
                pageNow:1,
                total:0
          }
      },
      mounted(){
          this.getSdata()
      },
      methods:{
         // 分页
        // 去任意页
        toPage(e){
            console.log(e);
            this.pageNow=e
            console.log(this.pageNow);
            this.getSdata()
        },
        //上一页
        prevPage(e){
            this.pageNow=this.pageNow-1;
            this.getSdata()
        },
        // 下一页
        nextPage(e){
               this.pageNow=this.pageNow+1;
               this.getSdata()
        },
           // 同意或者拒绝审核
          argreeS(  user_id,ifTrue){
            if(ifTrue==1){
                  axios.put('/users/changeOk',{
                   user_id,
                   isSuccess:true
               }).then((res)=>{
                  console.log(res);
                  if(res.data.code==1){
                     this.getSdata()
                  }
            })
            }else{
              axios.put('/users/changeOk',{
                     user_id,
                   isSuccess:false
               }).then((res)=>{
                  console.log(res);
                  if(res.data.code==1){
                     this.getSdata()
                  }
            })
            }
          },
          getSdata(){
             // 获取需要审核的用户
            axios.post('/users/shop',{
              limitpage:this.limitpage,
              pageNow:this.pageNow
              }).then((res)=>{
                  console.log(res);
                  this.Sdata=res.data.result;
                   this.total=res.data.total
            })
          },

      }
}
</script>

<style lang="less" scoped>
.All{
    background-color: rgb(255, 255, 255);
    padding: 50px;
}
</style>